<template>
	<view>
		<u--form :model="enterprise" labelWidth="auto" ref="form1">
			<u-form-item label="企业名称: " prop="enterprise.name" borderBottom ref="item1">
				<u--input v-model="enterprise.name" border="bottom" inputAlign="center"></u--input>
			</u-form-item>
			<u-form-item label="工商注册号: " prop="enterprise.registrationNo" borderBottom ref="item1">
				<u--input  v-model="enterprise.registrationNo" border="bottom" inputAlign="center"></u--input>
			</u-form-item>
			<u-form-item label="企业电话: " prop="enterprise.enPhone" borderBottom ref="item2">
				<u--input v-model="enterprise.enPhone" border="bottom" inputAlign="center"></u--input>
			</u-form-item>
			<u-form-item label="负责人: " prop="enterprise.chargePerson" borderBottom ref="item2">
				<u--input v-model="enterprise.chargePerson" border="bottom" inputAlign="center"></u--input>
			</u-form-item>
			<u-form-item label="负责人电话: " prop="enterprise.chargePhone" borderBottom ref="item3">
				<u--input v-model="enterprise.chargePhone" border="bottom" inputAlign="center"></u--input>
			</u-form-item>
			<u-form-item label="地址: " prop="enterprise.address" borderBottom ref="item3">
				<u--input v-model="enterprise.address" border="bottom" inputAlign="center"></u--input>
			</u-form-item>
			<u-form-item label="企业性质" prop="enterprise.natureId" borderBottom @tap="showSex = true;" ref="item1">
				<u--input v-model="enterprise.tbEnNature.name" border="bottom" inputAlign="center" disabled
					disabledColor="#ffffff" placeholder="请选择企业性质"></u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="企业描述: " prop="enterprise.desc" ref="item1">
				<u--textarea v-model="enterprise.desc" placeholder="请输入内容"></u--textarea>
			</u-form-item>
			<!-- <u-form-item label="企业图片: " ref="item1">
				<view>
					<image mode="aspectFill"
						style="display: inline-block; margin-right: 10rpx; width:100px; height:80px;"
						:src="item.photoUrl" v-for="(item,index) in enterprise.tbPhotoList" @click="delPhoto(item.id)">
					</image>
					<u-upload width="100px" height="80px" :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
						:maxCount="10"></u-upload>
				</view>
			</u-form-item> -->

		</u--form>
		<u-action-sheet :show="showSex" :actions="natureList" title="请选择企业性质" @close="showSex = false"
			@select="selectNature">
		</u-action-sheet>
		<view>
			<u-button type="primary" @click="saveEnterprise()" icon="plus">保存信息</u-button>
		</view>
	</view>
</template>

<script>
	import {
		findAllNature,
		delPhoto,
		saveEnterprise
	} from '@/api/enterprise.js'
	import {
		Toast
	} from '../../common/common.js'
	export default {
		data() {
			return {
				enterprise: {},
				natureList: [],
				showSex: false,
			}
		},
		methods: {
			findAllNature() {
				findAllNature({}).then(res => {
					this.natureList = res.data.data
				})
			},
			selectNature(nature) {
				// console.log(nature)
				this.enterprise.natureId = nature.id
				this.enterprise.tbEnNature = nature
			},
			saveEnterprise() {
				let user = uni.getStorageSync("user");
				this.enterprise.userId = user.id
				saveEnterprise(this.enterprise).then(res => {
					if (res.data.code == 20000) {
						uni.navigateBack({
							url: '/pageB/enterpriseList/enterpriseList'
						})
						Toast({
							title: '请等待审核'
						})
					}
				})
			}
		},
		onLoad() {
			this.findAllNature()
		}
	}
</script>

<style>

</style>
